package com.guomei.service.exam;

import com.guomei.bean.exam.domain.ExamAnswerDetail;
import com.guomei.bean.exam.domain.ExamUserAnswerVO;
import com.guomei.utils.Result;

import java.util.List;

/**
 * 考试答卷详情服务接口
 */
public interface ExamAnswerDetailService {
    
    /**
     * 根据ID查询
     */
    ExamAnswerDetail getById(Long id);
    
    /**
     * 查询所有
     */
    List<ExamAnswerDetail> getAll();
    
    /**
     * 条件查询（分页）
     */
    Result<?> getByCondition(ExamAnswerDetail examAnswerDetail);
    
    /**
     * 新增
     */
    boolean save(ExamAnswerDetail examAnswerDetail);
    
    /**
     * 批量新增
     */
    boolean batchSave(List<ExamAnswerDetail> examAnswerDetails);
    
    /**
     * 更新
     */
    boolean update(ExamAnswerDetail examAnswerDetail);
    
    /**
     * 根据ID删除
     */
    boolean removeById(Long id);
    
    /**
     * 批量删除
     */
    boolean batchRemove(List<Long> ids);
    
    /**
     * 根据答卷ID查询
     */
    List<ExamAnswerDetail> getByAnswerId(Long answerId);
    
    /**
     * 根据题目ID查询
     */
    List<ExamAnswerDetail> getByQuestionId(Long questionId);
    
    /**
     * 根据答卷ID和题目ID查询
     */
    ExamAnswerDetail getByAnswerIdAndQuestionId(Long answerId, Long questionId);
    
    /**
     * 根据答卷ID删除
     */
    boolean removeByAnswerId(Long answerId);
    
    /**
     * 根据题目ID删除
     */
    boolean removeByQuestionId(Long questionId);
    
    /**
     * 统计答卷详情数量
     */
    int countByAnswerId(Long answerId);
    
    /**
     * 统计题目答题数量
     */
    int countByQuestionId(Long questionId);
    
    /**
     * 计算答卷总分
     */
    Integer sumScoreByAnswerId(Long answerId);
    
    /**
     * 保存答题记录
     */
    Result<?> saveAnswer(Long answerId, Long questionId, String userAnswer);
    
    /**
     * 批量保存答题记录
     */
    Result<?> batchSaveAnswer(Long answerId, List<ExamAnswerDetail> answerDetails);
    
    /**
     * 评分
     */
    Result<?> scoreAnswer(Long answerDetailId, Integer score, String reviewRemark);
    
    /**
     * 批量评分
     */
    Result<?> batchScoreAnswer(List<ExamAnswerDetail> answerDetails);

    /**
     * 关联查询：按答卷ID
     */
    List<ExamUserAnswerVO> getUserAnswersByAnswerId(Long answerId);

    /**
     * 关联查询：按考试ID和用户ID
     */
    List<ExamUserAnswerVO> getUserAnswersByExamIdAndUserId(Long examId, Long userId);
}
